package com.eagle.depthinspringboot.configuration.bootstrapt;

import com.eagle.depthinspringboot.configuration.condition.ConditionalOnSystemProperty;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@ConditionalOnSystemProperty(name = "user.name", value = "Lenovo")
public class ConditionalBootstrap {

	@Bean
	@ConditionalOnSystemProperty(name = "user.name", value = "Lenovo")
	public String helloWorld(){
		return "Hello world";
	}

	public static void main(String[] args) {
		ConfigurableApplicationContext ctx = new SpringApplicationBuilder(ConditionalBootstrap.class)
				.web(WebApplicationType.NONE)
				.run(args);

		String hello = ctx.getBean("helloWorld",String.class);
		System.out.println(hello);

	}
}
